<?php
function smarty_function_inputchoice($params, $smarty) {
    $template = "inputchoice.tpl";
    $inputparams = "";
    $title = "";
    $hint = "";
    $validate = "";
    $id = "";
    $validationParams = "null";
    $itemlist = json_encode(array());
    $default = "Please select";
    $name = "";
    $itemservice = "";
    $width = 200;

    foreach ($params as $key=>$value) {
        if ($key == "title") { $title = $value; }
        else if ($key == "hint") { $hint = $value; }
        else if ($key == "validate") { $validation = $value; }
        else if ($key == "id") { $id = $value; }
        else if ($key == "validationparam") { $validationParams = $value; }
        else if ($key == "default") { $default = $value; }
        else if ($key == "itemservice") { $itemservice = $value; }
        else if ($key == "width") { $width = $value; }
        else if ($key == "itemlist") {
            $list = explode(",", $value);
            $itemlist = json_encode($list);
        }
        else {
            $inputparams .= "$key='$value' ";
        }
        if ($key == "name") { $name = $value; }
    }
    $smarty->assign("id", $id);
    $smarty->assign("validationparams", $validationParams);
    $smarty->assign("validate", $validation);
    $smarty->assign("params", $inputparams);
    $smarty->assign("hint", $hint);
    $smarty->assign("default", $default);
    $smarty->assign("itemlist", $itemlist);
    $smarty->assign("title", $title);
    $smarty->assign("name", $name);
    $smarty->assign("itemservice", $itemservice);
    $smarty->assign("width", $width);

    return $smarty->fetch("plugins/$template");
}

?>
